﻿
using System;
using KBEngine;
using UnityEngine;
using System.Collections.Generic;

public partial class NetGame : MonoBehaviour
{

    public void InstallLogin()
    {
        KBEngine.Event.registerOut("onVersionNotMatch", this, "onVersionNotMatch");
        KBEngine.Event.registerOut("onScriptVersionNotMatch", this, "onScriptVersionNotMatch");
        

        KBEngine.Event.registerOut("onLoginFailed", this, "onLoginFailed");
        KBEngine.Event.registerOut("onLoginSuccessfully", this, "onLoginSuccessfully");
        KBEngine.Event.registerOut("onLoginBaseappFailed", this, "onLoginBaseappFailed");
        KBEngine.Event.registerOut("onCreateAccountResult", this, "onCreateAccountResult");


        KBEngine.Event.registerOut("onLoginBaseapp", this, "onLoginBaseapp");

        KBEngine.Event.registerOut("Loginapp_importClientMessages", this, "Loginapp_importClientMessages");

        KBEngine.Event.registerOut("Baseapp_importClientMessages", this, "Baseapp_importClientMessages");
        KBEngine.Event.registerOut("Baseapp_importClientEntityDef", this, "Baseapp_importClientEntityDef");

        KBEngine.Event.registerOut("onReloginBaseappFailed", this, "onReloginBaseappFailed");
        KBEngine.Event.registerOut("onReloginBaseappSuccessfully", this, "onReloginBaseappSuccessfully");


        KBEngine.Event.registerOut("onReqAvatarList", this, "onReqAvatarList");
        KBEngine.Event.registerOut("onCreateAvatarResult", this, "onCreateAvatarResult");
        KBEngine.Event.registerOut("onRemoveAvatar", this, "onRemoveAvatar");
    }

    public void RemoveLogin()
    {

    }

    public void onReqAvatarList(Dictionary<UInt64, Dictionary<string, object>> avatarList)
    {

    }

    public void onCreateAvatarResult(Byte retcode, object info, Dictionary<UInt64, Dictionary<string, object>> avatarList)
    {
        if (retcode != 0)
        {
            err("Error creating avatar, errcode=" + retcode);
            return;
        }

        onReqAvatarList(avatarList);
    }

    public void onRemoveAvatar(UInt64 dbid, Dictionary<UInt64, Dictionary<string, object>> avatarList)
    {
        if (dbid == 0)
        {
            err("Delete the avatar error!(删除角色错误!)");
            return;
        }

        onReqAvatarList(avatarList);
    }


    

    public void onLoginBaseappFailed(UInt16 failedcode)
    {
        err("loginBaseapp is failed(登陆网关失败), err=" + KBEngineApp.app.serverErr(failedcode));
    }

    public void onLoginBaseapp()
    {
        info("connect to loginBaseapp, please wait...(连接到网关， 请稍后...)");
    }

    public void onReloginBaseappFailed(UInt16 failedcode)
    {
        err("relogin is failed(重连网关失败), err=" + KBEngineApp.app.serverErr(failedcode));
        startRelogin = false;
    }

    public void onReloginBaseappSuccessfully()
    {
        info("relogin is successfully!(重连成功!)");
        startRelogin = false;
    }


    public void Loginapp_importClientMessages()
    {
        info("Loginapp_importClientMessages ...");
    }

    public void Baseapp_importClientMessages()
    {
        info("Baseapp_importClientMessages ...");
    }

    public void Baseapp_importClientEntityDef()
    {
        info("importClientEntityDef ...");
    }
}